﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace cimdict
{
    public partial class ExportExcelForm : Form
    {
        public ExportExcelForm()
        {
            InitializeComponent();
        }

        private void exportInputButton_Click(object sender, EventArgs e)
        {
            if (exportExcelBox.Text != null && exportExcelBox.Text != "")
            {
                List<string> checkList = new List<string>();

                string[] lines = exportExcelBox.Text.Split('\n');
                foreach (string line in lines)
                {
                    string ln = line.Trim();
                    string[] parts = ln.Split('.');
                    if (parts.Length != 2)
                    {
                        parts = line.Split('\t');
                    }
                    if (parts.Length != 2) continue;

                    string full = parts[0].Trim() + "." + parts[1].Trim();
                    ExportFilter.add(full);
                    if (checkList.IndexOf(parts[0]) < 0)
                    {
                        checkList.Add(parts[0]);
                    }
                }

                if (CIMRepo.getAllClasses().Count == 0) CIMRepo.init();
                if (CIMRepo.getAllClasses().Count == 0) return;

                ExportExcel exp = new ExportExcel();
                foreach (string chkcls in checkList)
                {
                    exp.printClass(chkcls, false);
                    exp.println("");
                }
            }
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void ExportExcelForm_KeyPress(object sender, KeyPressEventArgs e)
        {
        }
    }
}
